<template>
  <div id="accusation" style="width: 100%;height: 100%;">
    <el-container>
      <el-main  style="height: 100%;padding: 0;">
        <el-table
          :data="accusationListGame"
          stripe
          style="width: 100%;  ">
          <el-table-column label="游戏举报内容">
          <el-table-column prop="userId" label="举报人Id" width="100">
          </el-table-column>
          <el-table-column prop="discussContent" label="举报内容" >
          </el-table-column>
          <el-table-column prop="accusationContent" label="举报原因" >
          </el-table-column>
          <el-table-column prop="userId_accusation" label="被举报人Id" width="100">
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作">
            <template slot-scope="scope">
              <el-button @click="handleClickGame(scope.row)" type="text" size="small">删除</el-button>
              <el-button @click="CloseUser(scope.row)"  type="text" size="small">封禁被举报用户</el-button>
              <el-button @click="NoGame(scope.row)" type="text" size="small">取消</el-button>
            </template>
          </el-table-column>
          </el-table-column>
        </el-table>
        <el-table
          :data="accusationListMovie"
          stripe
          style="width: 100%;">
          <el-table-column label="电影举报内容">
          <el-table-column prop="userId" label="举报人Id" width="100">
          </el-table-column>
          <el-table-column prop="discussContent" label="举报内容" >
          </el-table-column>
          <el-table-column prop="accusationContent" label="举报原因" >
          </el-table-column>
          <el-table-column prop="userId_accusation" label="被举报人Id"  width="100">
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作">
            <template slot-scope="scope">
              <el-button @click="handleClickMovie(scope.row)" type="text" size="small">删除</el-button>
              <el-button @click="CloseUser(scope.row)"  type="text" size="small">封禁被举报用户</el-button>
              <el-button @click="NoMovie(scope.row)"  type="text" size="small">取消</el-button>
            </template>
          </el-table-column>
          </el-table-column>
        </el-table>
        <el-table
          :data="accusationListMusic"
          stripe
          style="width: 100%;">
          <el-table-column label="音乐举报内容">
          <el-table-column prop="userId" label="举报人Id" width="100">
          </el-table-column>
          <el-table-column prop="discussContent" label="举报内容" >
          </el-table-column>
          <el-table-column prop="accusationContent" label="举报原因" >
          </el-table-column>
          <el-table-column prop="userId_accusation" label="被举报人Id" width="100" >
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作">
            <template slot-scope="scope">
              <el-button @click="handleClickMusic(scope.row)" type="text" size="small">删除</el-button>
              <el-button @click="CloseUser(scope.row)"  type="text" size="small">封禁被举报用户</el-button>
              <el-button @click="NoMusic(scope.row)"  type="text" size="small">取消</el-button>
            </template>
          </el-table-column>
          </el-table-column>
        </el-table>
      </el-main>
    </el-container>
  </div>
</template>

<script>
    import api from "../../model/api";

    export default {
        name: "accusation",
      data(){
          return{
            accusationListGame:[],
            accusationListMovie:[],
            accusationListMusic:[],

          }
      },
      created() {
          this.getGameAccusation()
          this.getMovieAccusation()
          this.getMusicAccusation()
      },
      methods:{
          getGameAccusation(){
            api.getGameAccusation().then(res =>{
              this.accusationListGame = res.data
            })
          },
        getMovieAccusation(){
          api.getMovieAccusation().then(res =>{
            this.accusationListMovie = res.data
          })
        },
        getMusicAccusation(){
          api.getMusicAccusation().then(res =>{
            this.accusationListMusic = res.data
          })
        },
        async handleClickGame(val){
            // console.log(val)
          const {data:res} = await this.$axios.post('v1/deleteGameDiscuss',{discussId:val.discussId})
          const {data:red} = await this.$axios.post('v1/deleteGameAccusation',{discussId:val.discussId})
          if(res.code === 200 && red.code === 200){
            this.$message.success("删除成功")
            this.getGameAccusation()
          }
        },
        async handleClickMovie(val){
          // console.log(val)
          const {data:res} = await this.$axios.post('v1/deleteDiscuss',{discussId:val.discussId})
          const {data:red} = await this.$axios.post('v1/deleteMovieAccusation',{discussId:val.discussId})
          if(res.code === 200 && red.code === 200){
            this.$message.success("删除成功")
            this.getMovieAccusation()
          }
        },
        async handleClickMusic(val){
          // console.log(val)
          const {data:res} = await this.$axios.post('v1/deleteMusicDiscuss',{discussId:val.discussId})
          const {data:red} = await this.$axios.post('v1/deleteMusicAccusation',{discussId:val.discussId})
          if(res.code === 200 && red.code === 200){
            this.$message.success("删除成功")
            this.getMusicAccusation()
          }
        },
        async NoGame(val){
          const {data:red} = await this.$axios.post('v1/deleteGameAccusation',{discussId:val.discussId})
          if(red.code === 200){
            this.$message.success("取消成功")
            this.getGameAccusation()
          }
        },
        async NoMovie(val){
          const {data:red} = await this.$axios.post('v1/deleteMovieAccusation',{discussId:val.discussId})
          if(red.code === 200){
            this.$message.success("取消成功")
            this.getMovieAccusation()
          }

        },
       async NoMusic(val){
          const {data:red} = await this.$axios.post('v1/deleteMusicAccusation',{discussId:val.discussId})
          if(red.code === 200){
            this.$message.success("取消成功")
            this.getMusicAccusation()
          }
        },
        async CloseUser(val){
            // console.log(val)
          const {data:res} = await this.$axios.post('v1/updateUserRoot',{userId:val.userId_accusation,rootCode:400})
          if(res.code === 200){
            this.$message.success('封禁成功')
          }

        }
      }
    }
</script>

<style lang="less" scoped>
.el-table{
  background-color: var(--theme-bgColor-aside-nav);
}

</style>
